﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using EngineGame;
namespace WarsOnRiceFields.Object
{
    /// <summary>
    /// Lớp con chuột
    /// </summary>
    class Mice
    {
        const float vMax = 0.5f;
        const float vMin = 0.1f;
        private Sprite sMice;
        private int x;
        private int y;
        private float vx;
        private Rectangle rect;
        public bool isAvailable;
        public Mice(int _x, int _y, Sprite mice)
        {
            sMice = mice;
            x = _x;
            y = _y;
            vx = vMin;
            isAvailable = true;
        }

        public void Update(GameTime gameTime)
        {
            sMice.Next(gameTime);
            x = (int)vx * gameTime.ElapsedGameTime.Milliseconds;
            rect = new Rectangle(x, y, sMice.Size.Width, sMice.Size.Height);
        }

        public void Draw(SpriteBatch sprite)
        {
            if (isAvailable)
            {
                sMice.Position = new Vector2(x, y);
                sMice.Draw(sprite);
            }
        }
    }
}
